<template>
  <view
    v-show="show"
    ref="ani"
    class="to-top animated"
    :class="show ? 'fadeIn' : ''"
  >
    <text class="dyicon icon-12" @click="toTopScorll"></text>
  </view>
</template>

<script>
  export default {
    name: 'toTop',
    props: {
      show: {
        type: Boolean,
        default: true,
      },
    },
    data() {
      return {};
    },
    methods: {
      // 回到顶部
      toTopScorll() {
        // uni.pageScrollTo({scrollTop: 0, duration: 50})
        this.$emit('toTopScorll');
      },
    },
  };
</script>

<style lang="less" scoped>
  .to-top {
    position: fixed;
    right: 16rpx;
    bottom: 110rpx;
    width: 60rpx;
    height: 50rpx;
    background-color: #666;
    cursor: pointer;
    text-align: center;
    white-space: normal;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 998;
    text {
      color: #fff;
      font-size: 40rpx;
    }
  }
</style>
